package com.hgy.hhao.springboot_vue;

import com.hgy.hhao.CommonConfig;
import com.hgy.hhao.springboot_vue.anno.EnableCommonConfig;
import com.hgy.hhao.springboot_vue.config.CommonImportSelector;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Import;

//启动类
@SpringBootApplication//组合注解：@SpringBootConfiguration + @EnableAutoConfiguration + @ComponentScan
/*
 * @ComponentScan(默认是项目包与子文件包下),衍生包 ↓
 * @Controller
 * @Service
 * @Repository: 用于持久层，数据库访问类上（由于与mybatis整合，用的少）
 * @Bean：用于方法上，表示该方法返回的对象需要交给spring容器管理
 */
//@Import(CommonConfig.class)//方法2：导入配置类
//@Import({CommonConfig.class,CommonConfig.class,CommonConfig.class,CommonConfig.class})
//@Import(CommonImportSelector.class)//方法3：导入配置类
@EnableCommonConfig//自定义注解
public class SpringbootVueApplication {

    public static void main(String[] args) {
        ConfigurableApplicationContext context = SpringApplication.run(SpringbootVueApplication.class, args);
        System.out.println(context.getBean("自定义"));
    }

}
/* 不建议：启动类不应该做修改
        ConfigurableApplicationContext context = SpringApplication.run(SpringbootVueApplication.class, args);
        Test bean = context.getBean(Test.class);
        System.out.print(bean);
    }

    @Bean
    public Test test() {
        return new Test();
    }
}
class Test {
    public String toString() {
        return "test";
    }
}*/